package trivia;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JLabel;
import java.awt.Rectangle;

public class ErrorFrame extends JDialog {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5127321015049121191L;
	private JDialog jErrorDialog = null;  //  @jve:decl-index=0:visual-constraint="165,64"
	private JPanel jErrorContentPane = null;
	private JButton Okbutton = null;
	private JLabel jMsgLabel = null;
	
	
	public ErrorFrame (String msg) {
		JDialog err = getJErrorDialog(msg);
		this.setLayout(new BorderLayout());
		
		err.setVisible(true);
	}

	/**
	 * This method initializes jErrorDialog	
	 * 	
	 * @return javax.swing.JDialog	
	 */
	private JDialog getJErrorDialog(String msg) {
		if (jErrorDialog == null) {
			jErrorDialog = new JDialog();
			jErrorDialog.setSize(new Dimension(219, 131));
			jErrorDialog.setVisible(true);
			jErrorDialog.setTitle("Error");
			jErrorDialog.setContentPane(getJErrorContentPane(msg));
		}
		return jErrorDialog;
	}

	/**
	 * This method initializes jErrorContentPane	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJErrorContentPane(String msg) {
		if (jErrorContentPane == null) {
			jMsgLabel = new JLabel();
			jMsgLabel.setText(msg);
			jMsgLabel.setBounds(new Rectangle(12, 9, 187, 50));
			jErrorContentPane = new JPanel();
			jErrorContentPane.setLayout(null);
			jErrorContentPane.add(getOkbutton(), null);
			jErrorContentPane.add(jMsgLabel, null);
		}
		return jErrorContentPane;
	}

	/**
	 * This method initializes Okbutton	
	 * 	
	 * @return java.awt.Button	
	 */
	private JButton getOkbutton() {
		Okbutton = new JButton("Ok");
		Okbutton.setBounds(new Rectangle(56, 67, 105, 25));
		Okbutton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent e) {
				jErrorDialog.dispose();
				}
		});
		
		return Okbutton;
	}

}
